/**
 * 
 */
package com.paypal.melearning.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.paypal.melearning.domain.Board;
import com.paypal.melearning.domain.Comment;
import com.paypal.melearning.domain.ContentType;
import com.paypal.melearning.domain.Pin;
import com.paypal.melearning.domain.User;

/**
 * @author Prasad
 * 
 *         this will need to be moved to Test Fixtures
 * 
 */
public class TestUtil {
	
	private static List<Board> mockBoards = new ArrayList<Board>();

	static{
		mockBoards.add(getDefaultBoard());
	}
	
	public static List<Board> getBoards(){
		System.out.println("Mock Boards Size == " +mockBoards.get(0).getPins().size());
		return mockBoards;
	}
	public static List<Pin> getDefaultPins() {

		List<Pin> defPins = new ArrayList<Pin>();
		defPins.addAll(getDefPins());
		
		return defPins;
	}

	private static Collection<? extends Pin> getDefPins() {
		List<Pin> defPins = new ArrayList<Pin>();
		Pin docPin = getDocPin();
		defPins.add(docPin);
		Pin imgPin = getImgPin();
		defPins.add(imgPin);
		Pin videoPin = getVideoPin();
		defPins.add(videoPin);
		Pin pdfPin = getPdfPin();
		defPins.add(pdfPin);
		Pin pptPin = getPptPin();
		defPins.add(pptPin);
		Pin webPin = getWebPin();
		defPins.add(webPin);

		return defPins;
	}

	private static User getDefaultUser() {
		return new User("Prasad");
	}

	private static Pin getWebPin() {

		Pin webPin = new Pin();
		webPin.setContentURL("http://en.wikipedia.org/wiki/PayPal");
		webPin.setCreatedBY(getDefaultUser());
		webPin.setDescription("Learn the basics of how to integrate Express Checkout with your website. " +
				"See where Express Checkout goes on your site. Learn where your site needs to call the API.");
		webPin.setPinId(1);
		webPin.setPinName("Express Checkout Integration Guide ");
		webPin.setType(ContentType.WEB.name());

		return webPin;
	}

	private static Pin getPptPin() {

		Pin pptPin = new Pin();
		pptPin.setContentURL("http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=6&ved=0CFoQFjAF&url=http%3A%2F%2F" +
				"www.frbatlanta.org%2Fnews%2FCONFEREN%2Fpayments04%2FVerjeePan1.ppt&ei=E2qhT-rdCYS3rAf3sMXUCA&usg=" +
				"AFQjCNGRYFwti6hvnDxp40a9knd26JHMvQ&sig2=BlTCqUfeY4B8lykV0xXLNA");
		pptPin.setCreatedBY(getDefaultUser());
		pptPin.setPinName("PayPal Payments Overview");
		pptPin.setPinId(2);
		pptPin.setDescription("Creating a new global standard for online payments");
		pptPin.setType(ContentType.PPT.name());

		return pptPin;

	}

	private static Pin getPdfPin() {

		Pin pdfPin = new Pin();
		pdfPin.setContentURL("https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_ExpressCheckout_AdvancedFeaturesGuide.pdf");
		pdfPin.setCreatedBY(getDefaultUser());
		pdfPin.setPinName("Express Checkout Advanced Features Guide ");
		pdfPin.setPinId(3);
		pdfPin.setDescription("Learn about advanced features that enhance your integration of Express Checkout, " +
				"such as customizing PayPal payment pages to match the look of your website and updating shipping charges as buyers make changes on the PayPal review page.");
		pdfPin.setType(ContentType.PDF.name());

		return pdfPin;

	}

	private static Pin getVideoPin() {

		Pin videoPin = new Pin();
		videoPin.setContentURL("http://www.youtube.com/v/meXvxkn1Y_8&hl=en_US&fs=1&");
//		videoPin.setContentURL("http://youtu.be/sLfm0Wwdikg");
		videoPin.setCreatedBY(getDefaultUser());
		videoPin.setPinName("What is PayPal? demo - YouTube");
		videoPin.setPinId(4);
		videoPin.setDescription("How to Pay via PayPal Without a PayPal Account ");
		videoPin.setType(ContentType.VIDEO.name());

		return videoPin;

	}

	private static Pin getImgPin() {

		Pin imgPin = new Pin();
		imgPin.setContentURL("http://www.epages.com/global/img/partner/paypal-german.jpg");
		imgPin.setCreatedBY(getDefaultUser());
		imgPin.setDescription("How PayPal Works");
		imgPin.setPinId(5);
		imgPin.setPinName("How PayPal Works");
		imgPin.setType(ContentType.IMAGE.name());
		
		return imgPin;

	}

	private static Pin getDocPin() {

		Pin docPin = new Pin();
		docPin.setContentURL("http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CEEQFjAC&url=http%3A%2F%2Fwww.tees.ac.uk%2Fdocs%2F"
				+ "docrepo%2FHuman%2520resources%2520documents"
				+ "%2FHolidays%2520and%2520Bank%2520Holidays.doc&ei=W2OhT96VFcLhrAeK3pT6CA&usg=AFQjCNExPozjTwJfDv4GNuBGRHkvxQ4l-A&sig2=sy1S6ZkgVnqnJy_KH_JPxg");
		docPin.setCreatedBY(getDefaultUser());
		docPin.setDescription("Holidays List");
		docPin.setPinId(6);
		docPin.setPinName("Holidays List");
		docPin.setType(ContentType.DOCUMENT.name());
		addComment(docPin,"The doc provides the Holiday List of UK");
		return docPin;

	}

	public static List<Board> getDefaultBoards() {
		List<Board> defBoards = new ArrayList<Board>();
		defBoards.add(getDefaultBoard());
		return defBoards;
	}

	private static Board getDefaultBoard() {
		Board defBoard = new Board("PayPal Merchants");
		defBoard.setCreatedBY(getDefaultUser());
		defBoard.setPins(getDefaultPins());
		return defBoard;
	}
	
	private static Comment getDefaultComment(){
		Comment comment = new Comment("Useful Read for new Hires", getDefaultUser());
		
		return comment;
	}
	
	
	private static void addComment(Pin pin, String commentStr){
		Comment comment =  new Comment(commentStr, getDefaultUser());
		pin.getComment().add(comment);
	}
}
